package com.spsyry.pay.listener;

import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
import com.spsyry.pay.constatant.RabbitmqConstantCompany;

import java.io.IOException;

@Component
@RabbitListener(queues = RabbitmqConstantCompany.MQ_QUEUE_NAME)
@Slf4j
public class RabbitmqLisenerCompany {

    @RabbitHandler
    public void handler(String str , Message message, Channel channel) throws Exception {
        log.info("接收到的消息---{}",str);
        //消息接收成功
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
        //不重新入队
//        channel.basicNack(message.getMessageProperties().getDeliveryTag(),false,false);

//        channel.basicNack(message.getMessageProperties().getDeliveryTag(),false,true);
    }
}
